import logging

def init_log(logfile: str):
    logging.basicConfig(
        filename=logfile, 
        filemode='w', 
        level=logging.INFO, 
        format='%(asctime)s - %(name)s - %(levelname)s - %(message)s', 
    )

def infomsg(logfile: str, msg: str):
    if logfile is None:
        print(msg)
    else:
        logging.info(msg)

def errormsg(logfile: str, msg: str):
    if logfile is None:
        print('error' + msg)
    else:
        logging.error(msg)

if __name__ == '__main__':
    init_log(logfile='test.log')
    logging.info('hello world')